import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '警戒颜色',
    align:"center",
    dataIndex: 'color',
    customRender: ({ text }) => {
      // 修改颜色和文字逻辑：新增98对应橙色和安全库存预警
      const color = text === '99' ? 'red' : text === '98' ? 'orange' : 'green';
      const content = text === '99' ? '低于MIN值' : text === '98' ? '安全库存预警' : '正常';
      return render.renderTag(content, color);
    }
   },
   {
    title: '零件号',
    align:"center",
    dataIndex: 'avpart'
   },
   {
    title: 'Min值',
    align:"center",
    dataIndex: 'v6minq'
   },
   {
    title: '描述',
    align:"center",
    dataIndex: 'avdes1'
   },
   {
    title: '现有库存',
    align:"center",
    dataIndex: 'bxqtohSum'
   },
   {
    title: '库位',
    align:"center",
    dataIndex: 'bxstok'
   },
   {
    title: '差异数量',
    align:"center",
    dataIndex: 'queshi'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "警戒颜色",
    field: 'color',
    component: 'JSelectMultiple',
    componentProps:{
        dictCode:"red_yello_select"
    },
    colProps: {span: 4},
 },
	{
      label: "零件号",
      field: 'avpart',
      component: 'JInput',
      colProps: {span: 4},
 	},
  //    {
  //     label: "Min值",
  //     field: "v6minq",
  //     component: 'JRangeNumber',
  //     colProps: {span: 4},
	// },
	{
      label: "描述",
      field: 'avdes1',
      component: 'JInput',
      colProps: {span: 6},
 	},
  //    {
  //     label: "现有库存",
  //     field: "bxqtohSum",
  //     component: 'JRangeNumber',
  //     colProps: {span: 4},
	// },
	// {
  //     label: "库位",
  //     field: 'bxstok',
  //     component: 'Input',
  //     colProps: {span: 6},
 	// },
     {
      label: "差异数量",
      field: "queshi",
      component: 'JRangeNumber',
      //colProps: {span: 6},
	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '零件号',
    field: 'avpart',
    component: 'Input',
  },
  {
    label: 'Min值',
    field: 'v6minq',
    component: 'InputNumber',
  },
  {
    label: '描述',
    field: 'avdes1',
    component: 'Input',
  },
  {
    label: '现有库存',
    field: 'bxqtohSum',
    component: 'InputNumber',
  },
  {
    label: '库位',
    field: 'bxstok',
    component: 'Input',
  },
  {
    label: '差异数量',
    field: 'queshi',
    component: 'InputNumber',
  },
  {
    label: '警戒颜色',
    field: 'color',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"red_yello_select"
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  avpart: {title: '零件号',order: 0,view: 'text', type: 'string',},
  v6minq: {title: 'Min值',order: 1,view: 'number', type: 'number',},
  avdes1: {title: '描述',order: 2,view: 'text', type: 'string',},
  bxqtohSum: {title: '现有库存',order: 3,view: 'number', type: 'number',},
  bxstok: {title: '库位',order: 4,view: 'text', type: 'string',},
  queshi: {title: '差异数量',order: 5,view: 'number', type: 'number',},
  color: {title: '警戒颜色',order: 6,view: 'list', type: 'string',dictCode: 'red_yello_select',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}